Skip to content

feat: load editable api console bodies - #31

Merged
jinbagi merged 1 commit into
masterfrom
codex/api-console-load-editable-body
Jul 3, 2026
Merged

feat: load editable api console bodies#31
jinbagi merged 1 commit into
masterfrom
codex/api-console-load-editable-body

Conversation

@jinbagi

@jinbagi jinbagi commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • load existing Admin API resources into API Console as editable request bodies
  • strip top-level read-only fields such as id, manager, username, create_time, and update_time from loaded request JSON
  • show which fields were removed and let users restore the raw response body when they need exact Admin API data
  • cover the GET existing route -> editable PUT body scenario in API Console E2E

Verification

  • .\node_modules.bin\tsc.CMD -b --pretty false
  • .\node_modules.bin\eslint.CMD src/routes/raw_api/index.tsx src/routes/raw_api/index.module.css e2e/tests/api-console.spec.ts --max-warnings=0 --no-warn-ignored
  • E2E_TARGET_URL=http://127.0.0.1:55173/ui/ playwright test e2e/tests/api-console.spec.ts --config=.tmp-playwright-chrome.config.ts --project=chrome --reporter=list --workers=1
  • corepack pnpm lint
  • corepack pnpm build

Copilot AI review requested due to automatic review settings July 3, 2026 11:38
@jinbagi
jinbagi merged commit ceaeaad into master Jul 3, 2026
1 check passed
@jinbagi
jinbagi deleted the codex/api-console-load-editable-body branch July 3, 2026 11:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an “editable load” workflow to the API Console so users can fetch an existing Admin API resource, automatically strip top-level read-only fields from the JSON, and optionally restore the original raw response body.

Changes:

  • Load an existing resource response into the request editor as an editable body (with read-only keys stripped and JSON keys normalized for readability).
  • Show an informational notice listing removed read-only fields and provide a “Use raw response” restore action.
  • Add Playwright E2E coverage for loading a GET route into an editable PUT-style body and restoring the raw response.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/routes/raw_api/index.tsx Implements editable-body loading, removed-keys notice UI, and raw-response restore behavior in the API Console.
src/routes/raw_api/index.module.css Styles the new loaded-body alert spacing.
e2e/tests/api-console.spec.ts Adds E2E coverage validating stripped read-only fields and the raw-restore action.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +465 to +469
const editableBody = getEditableLoadedBody(value);
setBody(editableBody.body);
setLoadedBodyNotice(
editableBody.removedKeys.length > 0
? {
Comment on lines +1005 to +1008
onChange={(nextValue) => {
setBody(nextValue ?? '');
setLoadedBodyNotice(null);
}}

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7909e212d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

};
}

const editableValue = stripPatchReadonlyFields(value);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't strip consumer usernames from loaded bodies

When the selected resource is Consumers, value contains the required top-level username, but this generic sanitizer removes it via PATCH_READONLY_KEYS. APISIX.ConsumerPut still requires username and the normal consumer PUT wrapper preserves it in the payload (src/types/schema/apisix/consumers.ts:24-39, src/apis/consumers.ts:44-48), so loading a consumer and sending the generated PUT body will fail Admin API validation instead of providing an editable update body.

Useful? React with 👍 / 👎.

};
}

const editableValue = stripPatchReadonlyFields(value);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Strip SSL validity fields from loaded bodies

For SSL resources, Admin API responses can include generated validity_start/validity_end fields (the SSL list reads validity_end), and the normal SSL write path explicitly deletes both before PUT (src/apis/ssls.ts:27-30). Because the new loader only removes PATCH_READONLY_KEYS, loading an SSL leaves those generated fields in the editable request body, so sending the unchanged loaded body through API Console includes fields that the regular API wrapper already treats as read-only.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants